#!/bin/bash
if [ -n "$1" ]; then
    data_date=$1
else
  data_date=`date -d '-1 days' +%F`
fi
vivo_user_log="
LOAD DATA INPATH '/warehouse/app_logs/vivo_logs/user_behavior_log (1).txt'
OVERWRITE INTO TABLE vivo_app_warehouse.vivo_user_log PARTITION (dt = '${data_date}');
"
vivo_user_info="
LOAD DATA INPATH 'hdfs://node101:8020/warehouse/app_basic/vivo_app_warehouse/vivo_user_info/${data_date}'
OVERWRITE INTO TABLE vivo_app_warehouse.vivo_user_info PARTITION (dt = '${data_date}');
"
vivo_device_info="
LOAD DATA INPATH 'hdfs://node101:8020/warehouse/app_basic/vivo_app_warehouse/vivo_device_info/${data_date}'
OVERWRITE INTO TABLE vivo_app_warehouse.vivo_device_info PARTITION (dt = '${data_date}');
"
vivo_region_info="
LOAD DATA INPATH 'hdfs://node101:8020/warehouse/app_basic/vivo_app_warehouse/vivo_region_info/${data_date}'
OVERWRITE INTO TABLE vivo_app_warehouse.vivo_region_info PARTITION (dt = '${data_date}');
"
vivo_app_info="
LOAD DATA INPATH 'hdfs://node101:8020/warehouse/app_basic/vivo_app_warehouse/vivo_app_info/${data_date}'
OVERWRITE INTO TABLE vivo_app_warehouse.vivo_app_info PARTITION (dt = '${data_date}');
"
/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${vivo_user_log}${vivo_user_info}${vivo_device_info}${vivo_region_info}${vivo_app_info}"